package objet;

import static org.junit.Assert.assertTrue;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * Classe de test de la classe Horloge
 * @author Kevin Pozderec,Faycal Abka
 *
 */
public class TestHorloge {
	
	Horloge h;

	@Before
	public void setUp() throws Exception {
		h = new Horloge();
	}

	@After
	public void tearDown() throws Exception {
		h = null;
	}

	@Test
	public void testTellMeDate() {
		String expected = h.d.getYear()+h.d.getMonth()+h.d.getDay()+" T "+h.d.getHour()+" : "+h.d.getMinute()+" : "+h.d.getSecond();
		assertTrue(expected.equals(h.tellMeDate()));
	}
	
	@Test
	public void testToXML(){
		
		StringBuffer expected = new StringBuffer();
		expected.append("<object oid=\""+h.oid+"\" type=\""+h.type+"\">");
		expected.append("<fields><field name=\"d\"><value><dateTime.iso8601>20121117T13:14:00</dateTime.iso8601></value></field></fields>");		
		expected.append("<methods>");
		expected.append("<method language=\"Java\">public String tellMeDate() {return d.getYear()+d.getMonth()+d.getDay()+\" T \"+d.getHour()+\" : \"+d.getMinute()+\" : \"+d.getSecond();}</method>");
		expected.append("</methods>");
		expected.append("</object>");
		String expected_str=expected.toString();
		
		assertTrue(expected_str.equals(h.toXML()));
	}
	

}
